home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 245 / xref4.doc < prev    next >
Text File  |  1988-02-07  |  4KB  |  90 lines

  1.                               XREF4
  2.           GFA Basic variable/procedure cross referencer
  3.                            by DAEDWARDS
  4.  
  5.      What it is:  XREF4 is a GFA Basic cross-referencer. Feed it a 
  6. .LST  file from GFA Basic,  and it produces a .LNM file (like  the 
  7. .LST  file with line numbers added) and a .XRF file showing  every 
  8. variable, label, and procedure name,  in alphabetical order, with the line 
  9. number of each reference to it in the program.
  10.  
  11.      (Qualifier:  you can use names like Gosub as  variables;  the 
  12. cross  referencer is not smart enough to deal with that,  so  such 
  13. things won't be included.)
  14.  
  15.      This is the 3rd version of My program; someone else wrote the 
  16. original GFA Basic XREF,  which only processed subroutine names. I 
  17. didn't like that, so I wrote XREF2, and am now releasing XREF4.
  18.  
  19.      Both the GFA Basic source and the compiled version are in the 
  20. archive.  I recommend using the compiled version,  and putting the 
  21. output on a RAMdisk,  for speed. But if you don't want to do that, 
  22. it is your business.
  23.  
  24.  
  25.  
  26.      History  and  hacker's notes:  Many mainframe  compilers  and 
  27. assemblers  can easily be persuaded to produce  a  cross-reference 
  28. showing  every place in the program where each variable  is  used. 
  29. This list is sometimes quite useful in finding program bugs.
  30.  
  31.      Some time back,  XREF was released for GFA Basic. However, it 
  32. only  cross  referenced  subroutines -  not  variables.  I  wasn't 
  33. satisfied with this. So I wrote XREF2, which would do variables as 
  34. well.
  35.  
  36.      However,  XREF2  had  some problems.  The  first  problem  to 
  37. surface  would become quite obvious three minutes after the  first 
  38. time  you started running it:  it would still be running.  It  was 
  39. incredibly slow. But that turned out to not be the worst: due to a 
  40. line I hadn't noticed in the GFA Basic manual,  if you referred to 
  41. the  same  variable too many times the thing would  get  lost  and 
  42. produce  a cross reference list best described  as  "garbage".  It 
  43. was,  fortunately,  recognisable as garbage, which is possibly the 
  44. smallest of virtues.
  45.  
  46.      When I discovered this, I decided it was time to write XREF3. 
  47. It  involved replacing one or two routines and minor  improvements 
  48. in others.
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.      When  XREF3 was just about done,  the last two or three  bugs 
  57. were being particularly stubborn, and I was thinking about how the 
  58. project  could have been done differently,  I suddenly decided  to 
  59. give  it  a try.  XREF3 was set aside 90% complete (one  of  those 
  60. projects that proceeded quickly to 90% complete and then  promised 
  61. to remain 90% complete forever), and I started on XREF4, expecting 
  62. either a quick success or a complete flop. I still have XREF3, but 
  63. haven't done anything with it in the last two months or so. 
  64.  
  65.      XREF4  is  virtually  a  complete  rewrite,  except  for  the 
  66. comments at the front.  The single biggest improvement is probably 
  67. the sort.  In XREF2 I went with a merge sort - a useful technique, 
  68. the  fastest  way  to  sort files which  won't  fit  in  memory  - 
  69. primarily because I could not tell in advance how big to dimension 
  70. an array holding all the variable names.
  71.  
  72.      But by the time of XREF4 I had some ideas, and worked out the 
  73. technique  of  making  an  array grow  (described  in  a  separate 
  74. document  with  a  much smaller and  simpler  sample  program,  in 
  75. GROWARAY.ARC), so I went with a quicksort. No file I/O at all, and 
  76. as a result many times faster.
  77.  
  78.      I  also  completely rewrote the front end,  which  reads  the 
  79. source  listing,  produces  the  numbered  listing,  and  extracts 
  80. names  to be cross-referenced.  It actually does more of the  work 
  81. now than it used to,  yet still runs in about 1/3 the time of  the 
  82. older version.
  83.  
  84.      A minor bug in XREF2 was a STOP statement that fouled up  the 
  85. compiler  (I didn't have the GFA Basic compiler when I wrote  it); 
  86. compiling  it  didn't  help that much  anyway,  because  file  I/O 
  87. operations  were  taking most of the time at  every  stage.  XREF4 
  88. compiles neatly, and runs signifigantly faster compiled. 
  89.  
  90.